<template>
  <div>
    <sheader :title="title" />
    <el-row>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="shh-host">
          <el-input v-model="form.host"></el-input>
        </el-form-item>
        <el-form-item label="shh-端口">
          <el-input v-model="form.port"></el-input>
        </el-form-item>
        <el-form-item label="shh-用户名">
          <el-input v-model="form.username"></el-input>
        </el-form-item>
        <el-form-item label="shh-密码">
          <el-input v-model="form.password" type="password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
        </el-form-item>
      </el-form>
    </el-row>
  </div>
</template>

<script>
import Sheader from '@/components/header'
import DataKit from '@/kit/DataKit'
export default {
  components: {
    Sheader
  },
  name: 'setting',
  data() {
    return {
      title: '设置',
      form: {
        ip: '',
        port: 22,
        username: '',
        password: ''
      }
    }
  },
  mounted() {
    let data = DataKit.find();
    if (data)
      this.form = data;
  },
  methods: {
    onSubmit() {
      let res = DataKit.save(this.form)
      if(res){
        this.$message({
          message: '操作成功',
          type: 'success'
        });
      }
      console.log(res);
    }
  }
}
</script>

